import { Component } from "react";
import {
  Button,
  Cell,
  Empty,
  Avatar,
  Grid,
  Image,
  Tabs,
  Table,
} from "@nutui/nutui-react-taro";
import styles from "./index.scss";
import { useModel } from "@/store";
import Taro, { useRouter } from "@tarojs/taro";
import { useState } from "react";
import { queryExamReport, queryExamReportDetail } from "@/services/report";
import { useEffect } from "react";
import { formatDate, calculateTime } from "@/utils/repeated";
import { useRef } from "react";
import Layout from "@/components/Layout";

// import { IconFont } from "@nutui/icons-react-taro";
export default () => {
  const { params } = useRouter();

  const { examAppointNo, itemNo } = params;

  const [data, setData] = useState({});
  const [resultList, setResultList] = useState([]);

  const ref = useRef();

  const getResultList = () => {
    queryExamReportDetail({
      examAppointNo,
      itemNo,
      pageSize: "999",
      pageNo: "1",
    }).then((res) => setResultList(res));
  };

  useEffect(() => {
    queryExamReport({ examAppointNo }).then((res) => {
      setData(res[0]);
      if (res[0]?.confirmDate) {
        getResultList();
      }
    });
  }, [examAppointNo]);

  return (
    <Layout title="检查报告">
    <view className={styles.examReportWarp}>
      <view className={styles.title}>{data.examItemName}</view>
      <view className={styles.examCard}>
        <view className={styles.dept}>{data.visitDept}</view>
        <view className={styles.time}>发布时间：{data.confirmDate}</view>
      </view>
      <view className={styles.examCard}>
        <view className={styles.examCardItem}>
          <view className={styles.text1}>检查描述:</view>
          <view className={styles.text2} style={{ whiteSpace: "pre-wrap" }}>
            {data.impersonality}
          </view>
        </view>
        <view className={styles.examCardItem}>
          <view className={styles.text1}>诊断意见:</view>
          <view className={styles.text2} style={{ whiteSpace: "pre-wrap" }}>
            {data.examReport}
          </view>
        </view>
        <view></view>
      </view>
    </view>
    </Layout>
  );
};
